package com.kavian.blog.collect.site;

import java.util.List;

import org.htmlparser.NodeFilter;
import org.htmlparser.Parser;
import org.htmlparser.filters.AndFilter;
import org.htmlparser.filters.HasAttributeFilter;
import org.htmlparser.filters.NodeClassFilter;
import org.htmlparser.tags.Div;
import org.htmlparser.util.NodeList;

import com.kavian.common.util.HttpClientUtil;


/**
 * iteye
 * 
 * @author kavian
 * 
 */
public class CollectItEye {
	private final String URL = "http://blog.csdn.net";
	private final String CHARSET = "UTF-8";

	/**
	 * 得到分页信息
	 * 
	 * @param url
	 * @return
	 */
	public List<String> searchPageUrl(String url) {
		try {
			String content = HttpClientUtil.httpGet(url, CHARSET);

			Parser parser = Parser.createParser(url, CHARSET);
			NodeFilter divFilter = new AndFilter(
					new NodeClassFilter(Div.class), new HasAttributeFilter(
							"class", "pagination"));
			NodeList divList = parser.extractAllNodesThatMatch(divFilter);
			
			if(divList.size() == 0){
				return null;
			}
				
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}